package com.hzit.hzb.core.controller.api;


import com.hzit.common.result.R;
import com.hzit.hzb.base.util.JwtUtils;
import com.hzit.hzb.core.pojo.entity.TransFlow;
import com.hzit.hzb.core.service.TransFlowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 交易流水表 前端控制器
 * </p>
 *
 * @author hbxfwf
 * @since 2024-08-27
 */
@RestController
@RequestMapping("/api/core/transFlow")
public class TransFlowController {

	@Autowired
	private TransFlowService transFlowService;

	@GetMapping("list")
	public R transFlow(@RequestHeader("token") String token){
		// 1. 获取userId
		Long userId = JwtUtils.getUserId(token);
		// 2. 获取登录用户的交易记录
		List<TransFlow> transFlows = transFlowService.findTransFlowByUserId(userId);
		return R.ok().data("list",transFlows);
	}
}

